<template>
	<view class="machineryleasing">
		<view class="head">
			<view class="search">
				<image @click="back" class="arrows" src="../../static/箭头左.png" mode=""></image>
				<input type="text" v-model="find" placeholder="找活、找工作" />
				搜索
			</view>
			<view class="classify">
				<view @click="showPopup" class="region">
					北京
					<image src="../../static/下箭头.png"></image>
					<my-tree :show="showAddress"></my-tree>
				</view>
				<view class="type">
					所有机械
					<image src="../../static/下箭头.png"></image>
				</view>
				<view class="recommend">
					求租信息
					<image src="../../static/下箭头.png"></image>
				</view>
			</view>
		</view>
		<mescroll-body @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
			<view class="marge">
				<contact-way class="module"></contact-way>
			</view>
			<view v-for="(message,index) in messages" :key="index">
				<view @click="goMessage" class="message">
					<view class="header">
						<view class="title">
							{{message.title}}
						</view>
						<view class="time">{{message.time}}</view>
					</view>
					<view class="content">
						<image src="../../static/logo.png" mode=""></image>
						<view class="pay-address">
							<view class="address">所在地区：{{message.address}}</view>
							<view class="status">求租状态:<view class="">{{message.status}}</view>
							</view>
							<view class="pay">支付方式：<view class="">{{message.pay}}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</mescroll-body>
		<view class="issue">发布机械消息</view>
	</view>
</template>

<script>
	import contactWay from '../../components/contactway.vue';
	export default {
		data() {
			return {
				upOption: {
					page: {
						size: 10 // 每页数据的数量,默认10
					},
					noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					empty: {
						tip: '暂无相关数据'
					}
				},
				messages: [{
						id: 1,
						title: "测试123456789asdasdaddad",
						top: true,
						image: "../../static/首页ok_29-17.jpg",
						concent: "招聘信息asdasdadadssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss",
						recruiting: true,
						address: "广州",
						time: "2020-10-15 10:03",
						status: "求租中",
						pay: "协商付款"
					},

					{
						id: 2,
						title: "测试123456789asdasdaddad",
						top: true,
						image: "../../static/首页ok_29-17.jpg",
						concent: "招聘信息asdasdadadssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss",
						recruiting: true,
						address: "广州",
						time: "2020-10-15 10:03",
						status: "求租中",
						pay: "协商付款"
					}
				]
			}
		},
		components: {
			'contactWay': contactWay
		},
		methods: {
			copy() {
				let self = this
				uni.setClipboardData({
					data: self.weChatNumb,
					success: function() {
						console.log("已复制" + self.weChatNumb)
					}
				})
			},
			upCallback(page) {
				let self = this.messages
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size; // 页长, 默认每页10条
				let time = 2000;
				uni.request({
					url: 'xxxx?pageNum=' + pageNum + '&pageSize=' + pageSize,
					success: (data) => {
						// 接口返回的当前页数据列表 (数组)
						let curPageData = 2;
						// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
						let curPageLen = curPageData.length;
						// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
						let totalPage = 2;
						// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
						let totalSize = 2;
						// 接口返回的是否有下一页 (true/false)
						let hasNext = false;

						//设置列表数据
						if (page.num == 1) self.messages = []; //如果是第一页需手动置空列表
						self.messages = self.messages.concat(curPageData); //追加新数据

						// 请求成功,隐藏加载状态
						//方法一(推荐): 后台接口有返回列表的总页数 totalPage
						this.mescroll.endByPage(curPageLen, totalPage);

						setTimeout(() => {
							this.mescroll.endSuccess(curPageLen)
						}, 2000)
					},
					fail: () => {
						//  请求失败,隐藏加载状态

						this.mescroll.endErr()
					},
				})

			},
			goMessage(id) {
				uni.navigateTo({
					url: "/pages/machineryleasing/machineryleasingDetails?id=" + id
				})
			},
			share() {
				this.show = true;
			},
			showPopup() {
				this.showAddress = true;
			},
			
			back() {
				uni.navigateBack()
			}
		},
	}
</script>
<style lang="scss">
	.module /deep/ .massage {
		margin-top: 220rpx;
		color: #ffaa00;
	}
</style>
<style lang="scss" scoped>
	.machineryleasing {
		width: 100vw;
		display: flex;
		flex-direction: column;
		background: #eaeaea;

		.head {
			position: fixed;
			background: #ffaa00;
			padding: 60rpx 50rpx 0 20rpx;
			margin-bottom: 30rpx;
			z-index: 8;

			.search {
				display: flex;
				color: #FFFFFF;
				font-size: 32rpx;
				justify-content: space-between;
				align-items: center;
				margin-right: 30rpx;

				.arrows {
					width: 50rpx;
					height: 50rpx;

				}

				input {
					padding-right: 20rpx;
					padding-left: 10rpx;
					background-color: #FFFFFF;
					color: black;
					width: 60vw;
					border-radius: 10rpx;
					height: 60rpx;
				}
			}

			.classify {
				display: flex;
				justify-content: space-between;
				background: #FFFFFF;
				margin-top: 6rpx;
				align-items: center;
				width: 100vw;
				margin-left: -20rpx;

				image {
					width: 30rpx;
					height: 30rpx;
					margin-left: 10rpx;
				}

				.region,
				.type,
				.recommend {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 30vw;
					height: 6vh;
				}
			}

			.marge {
				display: flex;
				flex-direction: column;
				background: #FFFFFF;
				margin-bottom: 20rpx;



				.advisory {
					height: 6vh;
					display: flex;
					margin-top: 10rpx;
					font-size: 26rpx;
					margin-left: 20rpx;

					.advisory-fish {
						color: #F0AD4E;
						line-height: 40rpx;
					}

					swiper {
						height: 4vh;
						width: 560rpx;

						.swiper-item {
							overflow: hidden;
							text-overflow: ellipsis;
						}
					}
				}
			}
		}

		.message {
			padding: 10rpx 20rpx;
			background: #FFFFFF;
			display: flex;
			flex-direction: column;
			margin-bottom: 20rpx;

			.header {
				display: flex;
				justify-content: space-between;
				font-size: 38rpx;
				white-space: nowrap;
				border-bottom: solid 1px #C8C9CC;

				.title {
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
			}

			.content {
				padding: 20rpx;
				display: flex;
				align-items: center;

				image {
					width: 160rpx;
					height: 160rpx;
					border-radius: 999rpx;
					margin-right: 20rpx;
				}

				.pay-address {
					font-size: 34rpx;

					.address {}

					.status,
					.pay {
						display: flex;
					}
				}
			}
		}

		.issue {
			position: fixed;
			bottom: 30rpx;
			left: 234rpx;
			color: #FFFFFF;
			background: #F0AD4E;
			padding: 6rpx 26rpx;
			font-size: 38rpx;
			border-radius: 999rpx;
		}
	}
</style>
